package disenioPantallas.elementos;

public class MyTableModel extends javax.swing.table.AbstractTableModel {

	private static final long serialVersionUID = 1L;
	private String[] columnNames;
	private Object[][] info;
	
	public MyTableModel(){
		super();
	}
	
	public boolean[] getEdits() {
		return edits;
	}

	public void setEdits(boolean[] edits) {
		this.edits = edits;
	}

	public String[] getColumnNames() {
		return columnNames;
	}

	private boolean[] edits;

	
/*	
	public MyTableModel(String[] columnNames,Object[][] info){
		
		this.columnNames=columnNames;
		if(info!=null)this.info=info; 
		this.edits=new boolean[this.columnNames.length];
		for(int i=0;i<this.columnNames.length;i++){
			edits[i]=false;
		}
	}
	
	*/
	@Override
	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public int getRowCount() {
		return info.length;
	}

	@Override
	public Object getValueAt(int x, int y) {
		return info[x][y];
	}

	public String getColumnName(int col) {
		return columnNames[col].toString().toUpperCase();
	}

	public void setColumnNames(String[] columnNames) {
		this.columnNames = columnNames;
	}

	public Object[][] getInfo() {
		return info;
	}

	public void setInfo(Object[][] info) {
		this.info = info;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Class getColumnClass(int c) {
		if(getRowCount()>0)
         return getValueAt(0, c).getClass(); 
		else return int.class;
     }
	
    public boolean isCellEditable(int row, int col) {
    	return edits[col];
     }
    
    public void setColumnEdit(int numero){
    	edits[numero]=true;
    }
    

    public void setValueAt(Object value,int row, int col){
        info[row][col] = value;
        fireTableCellUpdated(row, col);
    }
    
}